<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<script src="calendar_beans_v2.0_hide.js" type="text/javascript"
	charset="utf-8"></script>
<script src="jquery-1.7.2.js" type="text/javascript" charset="utf-8"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script>
	$(document).ready(function() {
		CalAddCss(); // !!제일 상단에 필수!!
		initCal({
			id : "cal1",
			type : "day",
			today : "y",
			icon : "y"
		});
		initCal({
			id : "cal7",
			type : "day",
			today : "y",
			icon : "y"
		});
		calClickEvent("cal1");
		$("#regMovieForm").submit(function(){
			 if($("#movie_title").val()==""){
				alert("영화제목을 입력해 주세요!");
				return false;
			}else if($("#running_time").val()==""){
				alert("러닝타임을 입력해 주세요!");
				return false;
			}else if(isNaN($("#running_time").val())){
				alert("러닝타임 숫자입력 해 주세요!");
				return false;
			}else if($("#genre_no").val()==""){
				alert("장르를 선택해 주세요!");
				return false;
			}else if($("#movie_grade_no").val()==""){
				alert("영화등급을 선택해 주세요!");
				return false;
			}else if($("#director").val()==""){
				alert("감독을 입력해 주세요!");
				return false;
			}else if($("#country_no").val()==""){
				alert("나라를 선택해 주세요!");
				return false;
			}else if($("#actor").val()==""){
				alert("배우를 입력해 주세요!");
				return false;
			}else if($("#uploadFile").val()==""){
				alert("영화 포스터를 등록해 주세요!");
				return false;
			}else if($("#distributor").val()==""){
				alert("배급사를 입력해 주세요!");
				return false;
			}else if($("#cal1").val()==""){
				alert("개봉일을 달력에서 선택해 주세요!");
				return false;
			}else if($("#cal7").val()==""){
				alert("종료일을 달력에서 선택해 주세요!");
				return false;
			}else if($("#homepage").val()==""){
				alert("홈페이지를 입력해 주세요!");
				return false;
			}else if($("#synopsis").val()==""){
				alert("synopsis를 입력해 주세요!");
				return false;
			}
			var flag=confirm("등록하시겠습니까?");
			if(flag==false){
				return false;
			}
		}); //regMovieForm
		$("#allCheck").click(function(){					
			var flag=true;
			$(":input:checkbox:[name=no]").each(function(){
				var subChecked=$(this).attr("checked");
				if(subChecked!=flag){
					$(this).click();
				}
			})
		});
 	});
		
</script>
<script>
	document.onkeydown = function(e) {
		key = (e) ? e.keyCode : event.keyCode;

		if (key == 8 || key == 116) {
			if (e) { //표준         
				e.preventDefault();
			} else { //익스용
				event.keyCode = 0;
				event.returnValue = false;
			}
		}
	}
</script>
<c:choose>
<c:when test="${sessionScope.vo.memberlevelinfoVO.member_level_no !=1}">
<script>
	alert("잘못된 접근입니다!");           
	location.href="mycinema.do?command=home_main";
</script>
</c:when>
<c:when test="${sessionScope.vo.memberlevelinfoVO.member_level_no ==1}">

<form method="post" action="admin.do" enctype="multipart/form-data" id="regMovieForm">
<font class='title'>영화 등록</font><hr color="#f5f5f5"> <input type="submit"  value="register">
<input type="hidden" name="command" value="registerMovie">
<hr>
<table border="1" cellspacing='0'>
	<tr align="center" >
		<td bgcolor="#f5f5f5"><b>영화제목</b></td>
		<td> <input type="text" name="movie_title" id="movie_title" ></td>
		<td bgcolor="#f5f5f5"><b>장 르</b></td>
		<td align="left"><select name="genre_no" id="genre_no">
				<option value="">&nbsp;&nbsp;&nbsp;- - - - - -&nbsp;&nbsp;&nbsp;</option>
				<c:forEach items="${requestScope.info.genre}" var="genre">
					<option value="${genre.genre_no}">${genre.genre}</option>
				</c:forEach>
			</select></td>
	</tr>
	<tr  align="center" >		
		<td bgcolor="#f5f5f5"><b>러닝타임</b></td>
		<td> <input type="text" name="running_time" id="running_time"></td>
		<td bgcolor="#f5f5f5"><b>등 급</b></td>	
		<td align="left"><select name="movie_grade_no"  id="movie_grade_no">
				<option value="">&nbsp;&nbsp;&nbsp;- - - - - -&nbsp;&nbsp;&nbsp;</option>
				<c:forEach items="${requestScope.info.grade}" var="grade">
					<option value="${grade.movie_grade_no}">${grade.movie_grade}</option>
				</c:forEach>
			</select></td>
	</tr>
	<tr  align="center">
		<td bgcolor="#f5f5f5"><b>감 독</b></td>
		<td> <input type="text" name="director" id="director"></td>
		<td bgcolor="#f5f5f5"><b>나 라</b></td>
		<td align="left"><select name="country_no" id="country_no">
				<option value="">&nbsp;&nbsp;&nbsp;- - - - - -&nbsp;&nbsp;&nbsp;</option>
				<c:forEach items="${requestScope.info.country}" var="country">
					<option value="${country.country_no}">${country.country}</option>
				</c:forEach>
			</select></td>		
	</tr>
	<tr  align="center">	
		<td bgcolor="#f5f5f5"><b>배 우</b></td>
		<td> <input type="text" name="actor" id="actor"></td>
		<td bgcolor="#f5f5f5"><b>포스터</b></td>
		<td align="left"><input type="file" name="uploadFile" id="uploadFile"></td>	
	</tr>
	<tr align="center">
		<td bgcolor="#f5f5f5"><b>배급사</b></td>
		<td> <input type="text" name="distributor" id="distributor"></td>
		<td bgcolor="#f5f5f5"><b>개봉일</b></td>
		<td align="left" valign="top" ><input type="text" id="cal1" size="37" name="opening_day" readonly="readonly" ></td>
	</tr>
	<tr align="center" >
		<td bgcolor="#f5f5f5"><b>홈페이지</b></td>
		<td> <input type="text" name="homepage" id="homepage"></td>
		<td bgcolor="#f5f5f5"><b>종료일</b></td>
		<td align="left" valign="top" ><input type="text" id="cal7" size="37" name="ending_day" readonly="readonly" ></td>
	</tr>
	<tr align="center">
		<td colspan='4' bgcolor="#f5f5f5"><b>synopsis</b></td>
	</tr>
	<tr align="center">
		<td colspan='4'> <textarea cols="100" rows="12" name="synopsis" id="synopsis"></textarea></td>
	</tr>
</table>
</form>
</c:when>
</c:choose>




